package com.usefullc.crawler.enums;


import com.fasterxml.jackson.annotation.JsonFormat;

/**
 * 请求错误状态
 */
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum RequestResultErrorStatusEnum {


    BAN(0, "屏蔽"),

    PROXY_ERROR(1, "代理失效"),

    OTHER(-1, "其他"),




    ;


    private int code;
    private String value;

    RequestResultErrorStatusEnum(int code, String value) {
        this.code = code;
        this.value = value;
    }

    public static RequestResultErrorStatusEnum getByCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (RequestResultErrorStatusEnum s : RequestResultErrorStatusEnum.values()) {
            if (s.getCode() == code) {
                return s;
            }
        }
        return null;
    }
    public static String getValueByCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (RequestResultErrorStatusEnum s : RequestResultErrorStatusEnum.values()) {
            if (s.getCode() == code) {
                return s.getValue();
            }
        }
        return null;
    }


    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getValue() {
        //国际化，重写desc TODO

        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

}
